package com.woniuxy.service.impl;

import com.woniuxy.dao.RbacManagerDao;
import com.woniuxy.entity.RbacManager;
import com.woniuxy.service.RbacManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
import java.util.Objects;
//Manger业务层实现类
//@Service+@Autowired
//等同于在xml中的 <bean id =“value的值” class =“RbacManagerServiceImpl类的全限定类名” autowire="byType"/>
@Service
//@Scope(value = "prototype")
public class RbacManagerServiceImpl implements RbacManagerService {
    @Autowired
    private RbacManagerDao rbacManagerDao;
    @Override
    public RbacManager findOne(int id) {
        System.out.println("这个是一个日志：我记录了id是："+id+"的用户的查询操作！");
        RbacManager one = rbacManagerDao.findOne(id);
        if (Objects.nonNull(one)){
            System.out.println("查询"+id+"用户成功！");
        }else {
            System.out.println("查询"+id+"用户失败！");
        }
        return one;
    }

    @Override
    public List<RbacManager> findAll() {
        List<RbacManager> all = rbacManagerDao.findAll();
        return all;
    }

    @Override
    @Transactional
    public int addOne(RbacManager rbacManager) {
        int i = rbacManagerDao.addOne(rbacManager);
        return i;
    }

    @Override
    public int updateOne(RbacManager rbacManager) {
        return rbacManagerDao.updateOne(rbacManager);
    }

    @Override
    public int deleteOne(int id) {
        return rbacManagerDao.deleteOne(id);
    }

    @Override
    public List<RbacManager> findByName(String username) {
        return rbacManagerDao.findOneByLikeName(username);
    }

    @Override
    public List<RbacManager> findByIds(Integer[] ids) {
        return rbacManagerDao.findByIds(ids);
    }

    @Override
    public int addOneForMap(Map<String, Object> userinfo) {
        return rbacManagerDao.addOneForMap(userinfo);
    }
}
